import QtQuick 2.0

MouseArea {
    required property Window window
    anchors.fill: parent
    property int windowOldXPosition
    property int windowOldYPosition
    property int mouseOldXPosition
    property int mouseOldYPosition

    onPressed: function (event){
        windowOldXPosition = window.x
        windowOldYPosition = window.y
        mouseOldXPosition = event.x
        mouseOldYPosition = event.y
    }
    onMouseXChanged: event => handleMove(event)
    onMouseYChanged: event => handleMove(event)

    function handleMove(event) {
        window.x = windowOldXPosition + (event.x - mouseOldXPosition)
        window.y = windowOldYPosition + (event.y - mouseOldYPosition)
    }
}
